home *** CD-ROM | disk | FTP | other *** search
- /* BlizKick EXTRES allocation API functions - example.
-
- Written by Harry "Piru" Sintonen, Jan 2000.
- Public Domain.
- */
-
- #include <exec/types.h>
- #include <exec/memory.h>
-
- #define __USE_SYSBASE 1
-
- #include <proto/exec.h>
- #include <proto/dos.h>
-
- #include "bkapi.h"
-
- /* protos */
- int __saveds main(void);
-
- #ifdef __SASC
- void __regargs __chkabort(void);
- void __regargs _CXBRK(void);
-
- struct ExecBase *SysBase;
- struct DosLibrary *DOSBase;
- #endif
-
- int __saveds main(void) {
- ULONG ver, avail, largest, size;
- APTR mem;
- struct Resident *res = NULL;
-
- #ifdef __SASC
- SysBase = *((struct ExecBase **)(4L));
- if ( (DOSBase = (struct DosLibrary *) OpenLibrary("dos.library", 37L))
- == NULL ) return 0;
- #endif
-
- Printf("bkapi example by Harry \"Piru\" Sintonen Jan 2000\n\n");
-
- ver = er_init();
-
- if (ver) {
-
- Printf("bkapi version %ld found!\n",ver);
-
- largest = er_availmem(MEMF_LARGEST);
- if (largest != 0xFFFFFFFF) {
- avail = er_availmem(0);
-
- Printf("bkapi EXTRES buffer memory available: %ld bytes largest: %ld bytes\n",
- avail, largest);
-
- size = largest;
- mem = er_allocmem(size, MEMF_CLEAR);
- if (mem) {
- Printf("er_allocmem(%ld, MEMF_CLEAR) = 0x%08lx\n", size, mem);
-
- /*Wait(0x0f000);*/
-
- er_free(mem, size);
- Printf("er_free(0x%08lx, %ld)\n", mem, size);
-
- size = 1234;
- mem = er_allocvec(size, MEMF_CLEAR);
- if (mem) {
- Printf("er_allocvec(%ld, MEMF_CLEAR) = 0x%08lx\n", size, mem);
-
- /*Wait(0x0f000);*/
-
- er_freevec(mem);
- Printf("er_vec(0x%08lx)\n", mem);
-
- er_lock();
- while ( (res = er_nextresident(res)) ) {
- Printf("resident: 0x%08lx name: %s idsting: %s\n",
- res, res->rt_Name, res->rt_IdString);
- }
-
- if ( (res = er_findresident("EXTRES Handler")) ) {
- Printf("er_findresident(\"EXTRES Handler\") = 0x%lx\n", res);
- }
-
- er_unlock();
-
- } else {
- Printf("er_allocvec(%ld, MEMF_CLEAR) failed!\n", size);
- }
-
- } else {
- Printf("er_allocmem(%ld, MEMF_CLEAR) failed!\n", size);
- }
-
- } else {
-
- Printf("BlizKick EXTRES buffer memheader INSANE!!\n");
-
- }
-
- } else {
-
- Printf("BlizKick EXTRES buffer API not found!\n");
-
- }
-
- #ifdef __SASC
- CloseLibrary( (struct Library *) DOSBase);
- #endif
- return 0;
- }
-